{%include file="header.html"%}
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>商品属性</h3>
    <div style="background:rgba(251,112,45,1);width:125px;height:40px;float:right;text-align:center;border-radius:5px;">
      <a class="tj_sx">
        <h5 style="padding:10px;color:#fff;">添加属性</h5>
      </a>
    </div>
  </div>
</div>
<div class="fixed_bottom">
    <form action="goods_sx.php" method="post">
        <div class="sx_wai">
            <div class="sx_con">
                {%foreach from=$region_list item=region%}
                <div class="sx_content">
                    <div class="sx_con_l"><input  type="text" name="name" onchange="jiaodain(this)" value="{%$region.name%}"  alt="{%$region.id%}" ></div>
                    <div class="sx_con_c"><input type="text" name="content" onchange="jiaodain(this)" value="{%$region.content%}" alt="{%$region.id%}"></div>
                    <div class="sx_con_r"><a href="goods_sx.php?act=del&id={%$region.id%}">删除</a></div>
                    <!--<div class="sx_xg"><input type="submit" value="修改"></div>-->
                    <div style="clear: both;"></div>
                </div>
                {%/foreach%}
            </div>
            <input type="hidden" name="act" value="goods_add" />
        </div>
        <div class="sx_tijiao"><input type="submit" value="提交">
        </div>
    </form>
</div>
</body>
<script>
    var con=`<div class="sx_content"><input type="hidden" name="id" value="" />
            <div class="sx_con_l"><input type="text" name="name" value=""></div>
    <div class="sx_con_c"><input type="text" name="content" value=""></div>
    <div class="sx_con_r"><a>自定义</a></div>
    <div style="clear: both;"></div>
    </div>`;
    $(".tj_sx").click(function(){
        $(".sx_con").append(con);
    }); 
    //元素改变的时候
    function jiaodain(th){
        var val=$(th).val();
        var id=$(th).attr("alt");
		var name=$(th).attr("name");
       $.post("goods_sx.php?act=edit",{id:id,val:val,name:name},function(data){
            if(data==1){layer.msg("操作成功！");}else{layer.msg("操作失败！");}
        })
    }
</script>
</html>